<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The EvIo class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="evidle.createstopped.html">« EvIdle::createStopped</a></li>
      <li style="float: right;"><a href="evio.construct.html">EvIo::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.ev.html">Ev</a></li>
    <li>The EvIo class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.evio" class="reference">
 <h1 class="title">The EvIo class</h1>
 
 <div class="partintro"><p class="verinfo">(PECL ev &gt;= 0.2.0)</p>

  <div class="section" id="evio.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <span class="classname"><strong class="classname">EvIo</strong></span>
    watchers check whether a file descriptor(or socket, or a stream castable
    to numeric file descriptor) is readable or writable in each iteration of
    the event loop, or, more precisely, when reading would not block the
    process and writing would at least be able to write some data. This
    behaviour is called
    <em class="emphasis">level-triggering</em>
    because events are kept receiving as long as the condition persists. To
    stop receiving events just stop the watcher.
   </p>
   <p class="para">
    The number of read and/or write event watchers per
    <code class="parameter">fd</code>
    is unlimited. Setting all file descriptors to non-blocking mode is also
    usually a good idea(but not required).
   </p>
   <p class="para">
    Another thing to watch out for is that it is quite easy to receive false
    readiness notifications, i.e. the callback might be called with
    <strong><code>Ev::READ</code></strong>
    but a subsequent
    <em class="emphasis">read()</em>
    will actually block because there is no data. It is very easy to get into
    this situation. Thus it is best to always use non-blocking I/O: An extra
    <em class="emphasis">read()</em>
    returning
    <strong><code>EAGAIN</code></strong>
    (or similar) is far preferable to a program hanging until some data
    arrives.
   </p>
   <p class="para">
    If for some reason it is impossible to run the
    <code class="parameter">fd</code>
    in non-blocking mode, then separately re-test whether a file descriptor is
    really ready. Some people additionally use
    <strong><code>SIGALRM</code></strong>
    and an interval timer, just to be sure thry won&#039;t block infinitely.
   </p>
   <p class="para">
    Always consider using non-blocking mode.
   </p>
  </div>

  <div class="section" id="evio.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">EvIo</strong>
     </span>
     <span class="ooclass">
      <span class="modifier">extends</span>
       <a href="class.evwatcher.html" class="classname">EvWatcher</a>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
      <var class="varname"><a href="class.evio.html#evio.props.fd">$<var class="varname">fd</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evio.html#evio.props.events">$<var class="varname">events</var></a></var>;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的属性 */</div>
    <div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-active">$<var class="varname">is_active</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.data">$<var class="varname">data</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.is-pending">$<var class="varname">is_pending</var></a></var>;</div>
<div class="fieldsynopsis"><span class="modifier">public</span>
      <var class="varname"><a href="class.evwatcher.html#evwatcher.props.priority">$<var class="varname">priority</var></a></var>;</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="methodname"><a href="evio.construct.html" class="methodname">__construct</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$fd</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$events</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
   <span class="initializer"> = ?</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
   <span class="initializer"> = ?</span></span><br>)</div>

    <div class="methodsynopsis dc-description"><span class="modifier">final</span>
   <span class="modifier">public</span>
   <span class="modifier">static</span>
   <span class="methodname"><a href="evio.createstopped.html" class="methodname">createStopped</a></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$fd</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$events</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$data</code>
    <span class="initializer"> = <strong><code>null</code></strong></span>
   </span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$priority</code>
    <span class="initializer"> = 0</span>
   </span><br>): <span class="type"><a href="class.evio.html" class="type EvIo">EvIo</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evio.set.html" class="methodname">set</a></span>(<span class="methodparam">
    <span class="type"><a href="language.types.declarations.html#language.types.declarations.mixed" class="type mixed">mixed</a></span>
     <code class="parameter">$fd</code>
   </span>, <span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$events</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 继承的方法 */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.clear.html" class="methodname">EvWatcher::clear</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.feed.html" class="methodname">EvWatcher::feed</a></span>(<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.getloop.html" class="methodname">EvWatcher::getLoop</a></span>(): <span class="type"><a href="class.evloop.html" class="type EvLoop">EvLoop</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.invoke.html" class="methodname">EvWatcher::invoke</a></span>(<span class="methodparam">
    <span class="type">int</span>
     <code class="parameter">$revents</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.keepalive.html" class="methodname">EvWatcher::keepalive</a></span>(<span class="methodparam">
    <span class="type">bool</span>
     <code class="parameter">$value</code>
   <span class="initializer"> = ?</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.setcallback.html" class="methodname">EvWatcher::setCallback</a></span>(<span class="methodparam">
    <span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span>
     <code class="parameter">$callback</code>
   </span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.start.html" class="methodname">EvWatcher::start</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span>
   <span class="methodname"><a href="evwatcher.stop.html" class="methodname">EvWatcher::stop</a></span>(): <span class="type"><span class="type void">void</span></span></div>

   }</div>

  </div>

  <div class="section" id="evio.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="evio.props.fd">
      <var class="varname">fd</var>
     </dt>

     <dd>

      <p class="para"/>
     </dd>

    
    
     <dt id="evio.props.events">
      <var class="varname">events</var>
     </dt>

     <dd>

      <p class="para"/>
     </dd>

    
   </dl>

  </div>

 </div>

 
















<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="evio.construct.html">EvIo::__construct</a> — Constructs EvIo watcher object</li><li><a href="evio.createstopped.html">EvIo::createStopped</a> — Create stopped EvIo watcher object</li><li><a href="evio.set.html">EvIo::set</a> — Configures the watcher</li></ul>
</div>
</div></div></body></html>